package dao

import (
	"shop_be/model"
	"shop_be/util"
)

func FindUserDao(name, psw string) (model.User, bool) {
	u := model.User{}
	notfound := util.Db.Where(&model.User{Name:name,Psw:psw}).First(&u).RecordNotFound()

	return u, notfound
}
func CreateUserDao(u model.User) {

	util.Db.Create(&u)
}
func UpdateUserDao(u model.User) {

	util.Db.Save(&u)
}

func FindUserById(id int) model.User {

	u := model.User{}
	util.Db.First(&u, id)
	return u
}

func FindAllUsers()[]model.User  {
	u:=[]model.User{}
	util.Db.Find(&u)
	return  u
}

